import {AllProps, PageProps} from "@/types/props.ts";


export interface PageData {
    id?: number;
    props?: PageProps;
    title?: string;
    desc?: string;
    coverImg?: string;
    uuid?: string;
    setting?: { [key: string]: any };
    isTemplate?: boolean;
    isHot?: boolean;
    isNew?: boolean;
    author?: string;
    copiedCount?: number;
    status?: number;
    user? : {
        gender: string;
        nickName: string;
        picture: string;
        userName: string;
    };
}

export interface EditorProps {
    // 供中间编辑器渲染的数组
    components: ComponentData[];
    // 当前编辑的是哪个元素，uuid
    currentElement: string;

}

export interface ComponentData {
    // id，uuid v4 生成
    id: string;
    // 业务组件库名称 l-text，l-image 等等
    name: 'l-text' | 'l-image' | 'l-shape';
    // 这个元素的 属性，属性请详见下面
    props: Partial<AllProps>;
    isHidden?: boolean;
    isLocked?: boolean;
    layerName?: string;
}

export interface UpdateComponentData {
    key: keyof AllProps | Array<keyof AllProps>;
    value: any;
    id: string;
    isRoot?: boolean;
}

export interface CommonHistoryData {
    type: string;
    idx: number;
}

export interface OperationHistoryData extends CommonHistoryData {
    oldData: ComponentData | null;
    newData: ComponentData | null;
}

export interface PositionHistoryData extends CommonHistoryData {
    newIdx: number;
}